package atguigu.xiaoxiduilie.shenchanzhe;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class Productor {

	public static void main(String[] args) throws IOException, TimeoutException {

		ConnectionFactory factory = new ConnectionFactory();
		factory.setUsername("test");
		factory.setPassword("123");
		factory.setHost("10.16.152.203");
		Connection conn = factory.newConnection();
		Channel channel = conn.createChannel();
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("DEVICE_CODE", "A2211080005160036");
		jsonObject.put("DATETIME_ACQUISITION", "2022-03-31 10:25:51");
		jsonObject.put("22110800090001010301", "2.049");
		jsonObject.put("22110800090001010302", "2.043");
		jsonObject.put("22110800090001010303", "63.6");
		jsonObject.put("22110800090001010304", "34");
		jsonObject.put("22110800090001010305", "57.2");
		jsonObject.put("22110800090001010306", "-0.2");
		jsonObject.put("22110800090001010307", "0.1");
		String readString = jsonObject.toJSONString();
//		readString = "aaa";
		byte[] messageBodyBytes = readString.getBytes();
		
		for (int i = 0; i < 100; i++) {
			channel.basicPublish("", "prod_jd_equip_warn_msg", null, messageBodyBytes);
			System.out.println(readString);
		}
		channel.close();
		conn.close();
	}
}
